package com.bestom.videoplay.util;

public class DataConversionUtil {


    public int bytesToInt(byte[] bytes, boolean highFirst){
        if (bytes.length < 4)
            return -1;
        // 高位在前
        if (highFirst)
            return ((bytes[0] & 0xFF) << 24) | ((bytes[1] & 0xFF) << 16) |
                ((bytes[2] & 0xFF) <<  8) | ((bytes[3] & 0xFF));
        // 低位在前
        return ((bytes[3] & 0xFF) << 24) | ((bytes[2] & 0xFF) << 16) |
                ((bytes[1] & 0xFF) <<  8) | ((bytes[0] & 0xFF));
    }

}
